/***************************************************************************
 *   Copyright (C) 2008 by Branan Riley   *
 *   branan@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef RENDERVIEW_H
#define RENDERVIEW_H

#include <QGLWidget>

class LwoLoader;
class AseLoader;

class RenderView : public QGLWidget
{
  Q_OBJECT
  public:
    RenderView(QWidget *parent = 0);
    RenderView(QGLContext *context, QWidget *parent = 0);
    RenderView(const QGLFormat &format,  QWidget *parent = 0);

    ~RenderView();

  public slots:
    void setModel(const QString &file);

  protected:
    void initializeGL();
    void resizeGL(int width, int height);
    void paintGL();
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);

  private:
    void setupGlPointers();
    void setupWidget();

    float *_vertices;
    float *_normals;
    float *_texcoords;
    unsigned int *_indices;
    unsigned int _index_count;
    float _rot_x, _rot_y, _zoom;
    QPoint _last_pos;

    LwoLoader *_lwo_loader;
    AseLoader *_ase_loader;
};

#endif
